package com.wdh.kjs.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.provider.Settings;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.fuiou.pay.FyPay;
import com.fuiou.pay.FyPayCallBack;
import com.fuiou.pay.util.AppConfig;
import com.fuiou.pay.util.MD5UtilString;
import com.google.gson.Gson;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest;
import com.wdh.kjs.Adapter.BankcardAdapter;
import com.wdh.kjs.R;
import com.wdh.kjs.http.Httpurl;

import com.wdh.kjs.http.response.MyCookieStore;
import com.wdh.kjs.model.JsonModel;
import com.wdh.kjs.model.JsonModel_my;
import com.wdh.kjs.model.PaidSendMessageModel;
import com.wdh.kjs.model.PlatformInfoForAppHtml;
import com.wdh.kjs.model.PlatformInfoForAppModel;
import com.wdh.kjs.util.ToastUtils;



import org.apache.http.impl.client.DefaultHttpClient;

import java.nio.channels.InterruptibleChannel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.zip.Inflater;


/**
 * Created by DH on 2016/4/27.
 */
public class InvestPaymentActivity extends Activity implements View.OnClickListener {
    private LinearLayout et_ii_transactionshenfenzheng;
    private String orderId;
    private TextView tv_invest;
    private ImageView iv_ii_back;
    private TextView tv_ii_agreement;
    private Button bt_invest_now1;
    private Button bt_ii_getVerificationCode;
    private Intent intent;
    private JsonModel jsonModel;
   public static HttpUtils myhttp;
    private EditText et_ii_transactionPassword;
    private EditText et_ii_verificationCode;
    private SharedPreferences share;
    private String st;
    private String itemId;
    private String phoneNumber;
    private String sendName;
    private EditText tv_ii_invest_money;
    private String a;
    private TextView tv_ii__available_amount;
    private double remain;
    private String levels;
    private String type;
    private RadioButton rb_payMethod;
    private RadioButton rb_payMethod2;
    private TimeCount time;
    private TextView item_ii_scale;
    private TextView tv_ii_name;
    private TextView item_ii_month;
    private TextView tv_ii_paymentMethod;
    private String gdItemType;
    private String sign;
    private int increaseMoney;
    private int lowLimitMoney;
    private TextView tv_ii_qitou;
    private TextView tv_ii_dizeng;
    private TextView tv_investbanknumber;
private String[] list;
    private String cardnumber;
    private ListView sp_invest;
    private JsonModel_my jsonModel_my;
    private BankcardAdapter bankcardAdapter;
    private LinearLayout ii_invest_bank;
    private List<HashMap<String, String>> datas=new ArrayList<HashMap<String,String>>();
    private LinearLayout ii_immediate_invest_code;
    private String state="1";
    private String name;
   private EditText et_ii_transactionshenfen;

//    private String mMchnt_Key = "5old71wihg2tqjug9kkpxnhx9hiujoqj";//测试
ProgressDialog m_pDialog;
    private String mMchnt_Key = "jvdqrdd9xbqe1roj1vefg2hdjlo80z0y";//测试
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_immediate_invest);
        FyPay.setDev(true);
        FyPay.init(InvestPaymentActivity.this);
        gdItemType = getIntent().getStringExtra("gdItemType");
        itemId = getIntent().getStringExtra("itemId");
        remain = Double.valueOf(getIntent().getStringExtra("remain"));
        increaseMoney = Integer.valueOf(getIntent().getStringExtra("increaseMoney"));
        lowLimitMoney = Integer.valueOf(getIntent().getStringExtra("lowLimitMoney"));
        share = getSharedPreferences("logininfo", MODE_PRIVATE);
        st = share.getString("loginToken", "");
        levels = share.getString("levels", "");
        phoneNumber=share.getString("phoneNumber", "");
        sendName =share.getString("nickName", "");
        type = share.getString("type", "");
        name ="abc";
        a = "xianxiazhifu";

        m_pDialog = new ProgressDialog(InvestPaymentActivity.this);
        m_pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        m_pDialog.setIcon(R.drawable.logo);
        m_pDialog.setTitle("温馨提示");
        m_pDialog.setMessage("不要着急，正在接收验证码哦~~~");
        m_pDialog.setCancelable(true);

        initView();
        tv_ii_qitou.setText(lowLimitMoney + "元");
        tv_ii_dizeng.setText(increaseMoney+"元");
        tv_ii__available_amount.setText(remain + "元");
        time = new TimeCount(60000*3, 1000);
        item_ii_scale.setText(InvestmentDetailActivity.tate2+"%");
        tv_ii_name.setText(InvestmentDetailActivity.ItemName);
                item_ii_month.setText( InvestmentDetailActivity.InterestDays+ "天");
        tv_ii_paymentMethod.setText(InvestmentDetailActivity.m);
        if (gdItemType.equals("2")) {

            list= new String[]{"借款协议-质押贷", "入仓托管协议", "动产质押合同", "入仓托管转让协议", "风险提示"};
            }
        if (gdItemType.equals("4")) {

            list= new String[]{"借款协议-金融贷", "风险提示"};
        }

    }

//    @Override
//    protected void onDestroy() {
//        super.onDestroy();
//    }

    @Override
    protected void onResume() {
        super.onResume();
        initView();
        tv_ii_invest_money.setText("");
        et_ii_transactionPassword.setText("");
    }
    private void initwebxianshang() {
        if (Integer.valueOf(levels) < 2) {
            falseDialogShow("请前往设置交易密码");
        } else {
            RequestParams params = new RequestParams();
            params.addBodyParameter("partyId", st);
            params.addBodyParameter("itemId", itemId);
            params.addBodyParameter("totalPrice", tv_ii_invest_money.getText().toString());
            params.addBodyParameter("tradePwd", et_ii_transactionPassword.getText().toString());
            params.addBodyParameter("orderPayModeNamePinYin","wangyinzhifu");
            params.addBodyParameter("bankCardId",cardnumber);
            myhttp = new HttpUtils();
            myhttp.send(HttpRequest.HttpMethod.POST, Httpurl.URL_PUSH_ORDER_UP, params, new RequestCallBack<String>() {

                @Override
                public void onSuccess(ResponseInfo<String> responseInfo) {


                    Gson gson = new Gson();
                    jsonModel = gson.fromJson(responseInfo.result, JsonModel.class);

                    if (jsonModel.success) {
                        DefaultHttpClient zpf = (DefaultHttpClient) myhttp.getHttpClient();
                        MyCookieStore.secondCookieStore = zpf.getCookieStore();

                        m_pDialog.dismiss();
                        String orderIdToPost=jsonModel.getOrderIdToPost();
                        orderId=jsonModel.getOrderId();
                        intent = new Intent(InvestPaymentActivity.this, CodeActivity.class);
                        intent.putExtra("partyId",st);
                        intent.putExtra("orderId",orderId);
                        intent.putExtra("bankCardId", cardnumber);
                        intent.putExtra("totalPrice", tv_ii_invest_money.getText().toString());
                        intent.putExtra("orderIdToPost", orderIdToPost);

                        intent.putExtra("bank_card_num",jsonModel.getMap().getBank_card_num());
                        intent.putExtra("sign_tp",jsonModel.getMap().getSign_tp());
                        intent.putExtra("back_url", jsonModel.getMap().getBack_url());
                        intent.putExtra("sign",jsonModel.getMap().getSign());
                        intent.putExtra("type", jsonModel.getMap().getType());
                        intent.putExtra("mchnt_cd",jsonModel.getMap().getMchnt_cd());
                        intent.putExtra("version",jsonModel.getMap().getVersion());
                        intent.putExtra("id_no", jsonModel.getMap().getId_no());
                        intent.putExtra("user_id", jsonModel.getMap().getUser_id());
                        intent.putExtra("name", jsonModel.getMap().getName());
                        intent.putExtra("order_amt",jsonModel.getMap().getOrder_amt());
                        intent.putExtra("id_type",jsonModel.getMap().getId_type());
                        intent.putExtra("mchnt_order_id", jsonModel.getMap().getMchnt_order_id());


                        startActivity(intent);
                        finish();
                    } else
                    {

                        falseDialogShow(jsonModel.getMsg()+"。"+jsonModel.getErrMsg());
                        m_pDialog.dismiss();
                    }
                }

                @Override
                public void onFailure(HttpException error, String msg) {

                    ToastUtils.showShort(InvestPaymentActivity.this, "网络异常！");
                }
            });



//            String MchNtCd = "0003910F0352416";
//            String MchntOrdId = et_ii_transactionshenfen.getText().toString();
//            String UserId = st;
//            String BankCaradNumber ="4563517501013883117" ;
////            String BankCaradNumber =cardnumber ;
//            String IdNo = et_ii_transactionshenfen.getText().toString();
//            String VERSION = "2.0";
//            String TYPE = "02";
//            String IdType = "0";
//            String BACKURL = "http://www-1.fuiou.com:18670/mobile_pay/update/receive.pay";
//            String m = TYPE + "|" + VERSION + "|"
//                    + MchNtCd + "|"
//                    + MchntOrdId + "|"
//                    + UserId + "|"
//                    + tv_ii_invest_money.getText().toString() + "|"
//                    + BankCaradNumber + "|" + BACKURL + "|"
//                    + name + "|"
//                    + IdNo + "|"
//                    + IdType + "|" + mMchnt_Key;
//            String Sing = MD5UtilString.MD5Encode(m);
//            Bundle bundle =new Bundle();
//            bundle.putString(AppConfig.MCHNT_CD, MchNtCd);
//            bundle.putString(AppConfig.MCHNT_AMT, tv_ii_invest_money.getText().toString());
//            bundle.putString(AppConfig.MCHNT_BACK_URL, BACKURL);
//            bundle.putString(AppConfig.MCHNT_BANK_NUMBER, BankCaradNumber);
//            bundle.putString(AppConfig.MCHNT_ORDER_ID, MchntOrdId);
//            bundle.putString(AppConfig.MCHNT_USER_IDCARD_TYPE,IdType);
//            bundle.putString(AppConfig.MCHNT_USER_ID,UserId);
//            bundle.putString(AppConfig.MCHNT_USER_IDNU,IdNo);
//            bundle.putString(AppConfig.MCHNT_USER_NAME,name);
//            bundle.putString(AppConfig.MCHNT_SING_KEY,Sing);
//            bundle.putString(AppConfig.MCHNT_SDK_SIGNTP,"MD5");
//            bundle.putString(AppConfig.MCHNT_SDK_TYPE,TYPE);
//            bundle.putString(AppConfig.MCHNT_SDK_VERSION,VERSION);
//
//            int i= FyPay.pay(InvestPaymentActivity.this, bundle, new FyPayCallBack() {
//
//
//                @Override
//                public void onPayComplete(String arg0, String arg1, Bundle arg2) {
//                    // TODO Auto-generated method stub
//
//                    Log.e("fuiou", "----------rspCode:"+arg0.toString());
//                    Log.e("fuiou", "----------rspDesc:"+arg1.toString());
//                    Log.e("fuiou", "----------extraData:"+arg2.toString());
//
//                }
//
//                @Override
//                public void onPayBackMessage(String arg0) {
//                    // TODO Auto-generated method stub
//
//                    Log.e("fuiou", "----------extraData:"+arg0.toString());
//                }
//            });
        }
    }

    private void initweb() {
        if (Integer.valueOf(levels) < 2) {
            falseDialogShow("请前往设置交易密码");
        } else {
            RequestParams params = new RequestParams();

            params.addBodyParameter("verificationCode", et_ii_verificationCode.getText() + "");
            params.addBodyParameter("partyId", st);
            params.addBodyParameter("itemId", itemId);
            params.addBodyParameter("totalPrice", tv_ii_invest_money.getText().toString());
            params.addBodyParameter("tradePwd", et_ii_transactionPassword.getText().toString());
            params.addBodyParameter("orderPayModeNamePinYin", a);

            HttpUtils http = new HttpUtils();
            http.configCookieStore(MyCookieStore.secondCookieStore);

            http.send(HttpRequest.HttpMethod.POST, Httpurl.URL_PUSH_ORDER, params, new RequestCallBack<String>() {

                @Override
                public void onSuccess(ResponseInfo<String> responseInfo) {


                    Gson gson = new Gson();
                    jsonModel = gson.fromJson(responseInfo.result, JsonModel.class);

                    if (jsonModel.success) {

                        ToastUtils.showShort(InvestPaymentActivity.this, "投资成功");
                        intent = new Intent(InvestPaymentActivity.this, InvestNowActivity.class);
                        intent.putExtra("money", tv_ii_invest_money.getText().toString());
                        startActivity(intent);
                    } else
//                    ToastUtils.showShort(InvestPaymentActivity.this, jsonModel.getMsg());
//                falseDialogShow(jsonModel.getMes());
                    {
                        String m = jsonModel.getMsg();
                        falseDialogShow(jsonModel.getMsg());
                    }
                }

                @Override
                public void onFailure(HttpException error, String msg) {

                    ToastUtils.showShort(InvestPaymentActivity.this, "网络异常！");
                }
            });
        }
    }

    private void initView() {
//        et_ii_transactionshenfenzheng = (LinearLayout) findViewById(R.id.et_ii_transactionshenfenzheng);
//        et_ii_transactionshenfen = (EditText) findViewById(R.id.et_ii_transactionshenfen);
        tv_investbanknumber = (TextView) findViewById(R.id.tv_investbanknumber);
        ii_invest_bank = (LinearLayout) findViewById(R.id.ii_invest_bank);
        tv_invest = (TextView) findViewById(R.id.tv_invest);
        ii_immediate_invest_code = (LinearLayout) findViewById(R.id.ii_immediate_invest_code);
        sp_invest = (ListView) findViewById(R.id.sp_invest);
        tv_ii_qitou = (TextView) findViewById(R.id.tv_ii_qitou);
        tv_ii_dizeng = (TextView) findViewById(R.id.tv_ii_dizeng);
        tv_ii_paymentMethod = (TextView) findViewById(R.id.tv_ii_paymentMethod);
        item_ii_month = (TextView) findViewById(R.id.item_ii_month);
        tv_ii_name = (TextView) findViewById(R.id.tv_ii_name);
        item_ii_scale = (TextView) findViewById(R.id.item_ii_scale);
        rb_payMethod2 = (RadioButton) findViewById(R.id.rb_payMethod2);
        rb_payMethod = (RadioButton) findViewById(R.id.rb_payMethod);
        et_ii_transactionPassword = (EditText) findViewById(R.id.et_ii_transactionPassword);
        tv_ii_invest_money = (EditText) findViewById(R.id.tv_ii_invest_money);
        et_ii_verificationCode = (EditText) findViewById(R.id.et_ii_verificationCode);
        iv_ii_back = (ImageView) findViewById(R.id.iv_ii_back);
        tv_ii_agreement = (TextView) findViewById(R.id.tv_ii_agreement);
        bt_invest_now1 = (Button) findViewById(R.id.bt_invest_now1);
        tv_ii__available_amount = (TextView) findViewById(R.id.tv_ii__available_amount);
        bt_ii_getVerificationCode = (Button) findViewById(R.id.bt_ii_getVerificationCode);

        rb_payMethod.setOnClickListener(this);
        iv_ii_back.setOnClickListener(this);
        rb_payMethod2.setOnClickListener(this);
        tv_ii_agreement.setOnClickListener(this);
        bt_invest_now1.setOnClickListener(this);
        bt_ii_getVerificationCode.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.rb_payMethod:
                sp_invest.setVisibility(View.GONE);
                ii_immediate_invest_code.setVisibility(View.VISIBLE);
//                et_ii_transactionshenfenzheng.setVisibility(View.GONE);
                state="1";
                ii_invest_bank.setVisibility(View.GONE);
                break;
            case R.id.rb_payMethod2:
//                falseDialogShow("对不起！暂时只支持线下支付");
//                rb_payMethod.setChecked(true);
//                rb_payMethod2.setChecked(false);
                Toast.makeText(InvestPaymentActivity.this,"请选择银行卡",Toast.LENGTH_SHORT).show();
                sp_invest.setVisibility(View.VISIBLE);
//                et_ii_transactionshenfenzheng.setVisibility(View.VISIBLE);
                ii_immediate_invest_code.setVisibility(View.GONE);
                initbangcardweb();
                state="2";
                break;
            case R.id.iv_ii_back:

                InvestPaymentActivity.this.finish();
                break;
            case R.id.tv_ii_agreement:
//                platformInfoForApp();

                AlertDialog.Builder builder = new AlertDialog.Builder(InvestPaymentActivity.this);

                builder.setItems(list, new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface arg0, int arg1) {
                        // TODO 自动生成的方法存根
                        if (gdItemType.equals("2")) {
                            if (arg1 == 0) {
                                sign = "3";
                            } else if (arg1 == 1) {
                                sign = "4";
                            } else if (arg1 == 2)
                                sign = "5";
                            else if (arg1 == 3)
                                sign = "6";
                            else if (arg1 == 4)
                                sign = "9";

                        } else if (gdItemType.equals("4")) {
                            if (arg1 == 0) {
                                sign = "7";
                            } else if (arg1 == 1) {
                                sign = "9";
                            }

                        }

                        arg0.dismiss();
                        intent = new Intent(InvestPaymentActivity.this, JieKuanXYActivity.class);
                        intent.putExtra("sign", sign);
                        startActivity(intent);
                    }
                });
                builder.show();

                break;
            case R.id.bt_ii_getVerificationCode: {
                if(!isLogin()){
                    falseDialogShow("您还未登录，请先登录！");
                    return;
                }
                time.start();
                intcode();
                break;
            }
            case R.id.bt_invest_now1:

//                int a = Integer.valueOf(tv_ii_invest_money.getText().toString());
                int b= (int) remain;
                if(!isLogin()){
                    falseDialogShow("您还未登录，请先登录！");
                    return;
                }

                if(type.equals("p")&&!levels.equals("3")){
                    falseDialogShow("未绑定银行卡");
                }
                 else if (tv_ii_invest_money.getText().toString().equals(""))
                    falseDialogShow("请输入投资金额");
                else if (et_ii_transactionPassword.getText().toString().equals(""))
                    falseDialogShow("请输入交易密码");
                else if (Integer.valueOf(tv_ii_invest_money.getText().toString())>b)
                    falseDialogShow("您的投资金额不能大于可投金额");
                else if ((Integer.valueOf(tv_ii_invest_money.getText().toString())-lowLimitMoney)%increaseMoney!=0)
                falseDialogShow("您投资的金额不符合要求");
                else if (state.equals("1"))
                    initweb();
                else if(state.equals("2")) {
                    m_pDialog.show();
                    initwebxianshang();
                }
                break;
        }
    }



    private void initbangcardweb() {
        RequestParams params = new RequestParams();
        params.addBodyParameter("partyId", st);

        HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, Httpurl.URL_BANKCARD_LIST, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                jsonModel_my = gson.fromJson(responseInfo.result, JsonModel_my.class);
//                Log.i("msg","666");
                if (jsonModel_my.success) {
                    bankcardAdapter=new BankcardAdapter(InvestPaymentActivity.this, initListViewData(),st);
                    sp_invest.setAdapter(bankcardAdapter);
                    sp_invest.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                        @Override
                        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                             cardnumber=jsonModel_my.getBankCardList().get(position).getBankCardId();
                            ii_invest_bank.setVisibility(View.VISIBLE);
                            tv_invest.setText(datas.get(position).get("bank")  );
                            tv_investbanknumber.setText("**** **** **** "+datas.get(position).get("bankcard_number"));
                            sp_invest.setVisibility(View.GONE);







                        }
                    });
                }
            }
            @Override
            public void onFailure(HttpException error, String msg) {
                ToastUtils.showShort(getApplicationContext(), "网络异常！");
            }
        });
    }
    private List<HashMap<String, String>> initListViewData() {
        datas = new ArrayList<>();
        for (int i = 0; i < jsonModel_my.getBankCardList().size(); i++) {
            HashMap<String, String> hashMap = new HashMap<>();
            switch (jsonModel_my.getBankCardList().get(i).getBankCardNameType()){
                case 0: hashMap.put("bank", "中国农业银行");break;
                case 1: hashMap.put("bank", "中国工商银行");break;
                case 2: hashMap.put("bank", "中国建设银行");break;
                case 3: hashMap.put("bank", "民生银行");break;
                case 4: hashMap.put("bank", "兴业银行");break;
                case 5: hashMap.put("bank", "交通银行");break;
                case 6: hashMap.put("bank", "中信银行");break;
                case 7: hashMap.put("bank", "平安银行");break;
                case 8: hashMap.put("bank", "广发银行");break;
                case 9: hashMap.put("bank", "招商银行");break;
                case 10: hashMap.put("bank", "中国银行");break;
                case 11: hashMap.put("bank", "浦发银行");break;
                case 12:hashMap.put("bank", "福建海峡银行");break;
                case 13:hashMap.put("bank", "光大银行");break;
                case 14:hashMap.put("bank", "恒丰银行");break;
                case 15:hashMap.put("bank", "华夏银行");break;
                case 16:hashMap.put("bank", "汇丰银行");break;
                case 17:hashMap.put("bank", "泉州银行");break;
                case 18:hashMap.put("bank", "厦门银行");break;
                case 19:hashMap.put("bank", "厦门国际银行");break;
                case 20:hashMap.put("bank", "上海银行");break;
                case 21:hashMap.put("bank", "香港恒生银行");break;
                case 22:hashMap.put("bank", "邮政银行");break;
                case 23:hashMap.put("bank", "浙商银行");break;


                default:break;
            }
            hashMap.put("bankcard_number", jsonModel_my.getBankCardList().get(i).getBankCardNum().substring(jsonModel_my.getBankCardList().get(i).getBankCardNum().length()-4,jsonModel_my.getBankCardList().get(i).getBankCardNum().length()));
            hashMap.put("bankcardId", jsonModel_my.getBankCardList().get(i).getBankCardId());
            hashMap.put("isMainCard", jsonModel_my.getBankCardList().get(i).getIsMainTradeCard());
            hashMap.put("bandCard_size", jsonModel_my.getBankCardList().size()+"");
            Log.i("msg", "是否是主卡  " + jsonModel_my.getBankCardList().get(i).getIsMainTradeCard());

            datas.add(hashMap);
        }
        return datas;
    }
    private void falseDialogShow(String hint) {
        View dialog = getLayoutInflater().inflate(R.layout.touzixinxi, null);
        TextView tv_dialog_false_hint = (TextView) dialog.findViewById(R.id.touzixinxi);
        tv_dialog_false_hint.setText(hint);
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setView(dialog);
        builder.create();
        final AlertDialog dialogShow = builder.show();
        tv_dialog_false_hint.setOnClickListener(new android.view.View.OnClickListener() {

            @Override
            public void onClick(View v) {
                dialogShow.dismiss();
            }
        });
    }

    class TimeCount extends CountDownTimer {
        public TimeCount(long millisInFuture, long countDownInterval) {
            super(millisInFuture, countDownInterval);
        }

        @Override
        public void onFinish() {// 计时完毕
            bt_ii_getVerificationCode.setText("发送验证码");
            bt_ii_getVerificationCode.setClickable(true);
        }

        @Override
        public void onTick(long millisUntilFinished) {// 计时过程
            bt_ii_getVerificationCode.setClickable(false);//防止重复点击
            bt_ii_getVerificationCode.setText(millisUntilFinished / 1000 + "s后可重新获取");
        }
    }

    private void intcode() {

        RequestParams params = new RequestParams();
        //  params.addBodyParameter("phoneNumber", phoneEdit.getText().toString().trim());
       // params.addBodyParameter("phoneNumber", "13506976146");
        params.addBodyParameter("phoneNumber",phoneNumber);
        params.addBodyParameter("sendName",sendName);
        final HttpUtils http = new HttpUtils();
        http.send(HttpRequest.HttpMethod.POST, Httpurl.URL_Paid_MSG, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                PaidSendMessageModel rlpsm = gson.fromJson(responseInfo.result, PaidSendMessageModel.class);

                DefaultHttpClient zpf = (DefaultHttpClient) http.getHttpClient();
                MyCookieStore.secondCookieStore = zpf.getCookieStore();

                bt_ii_getVerificationCode.setText("发送验证码");
//                if (!("0".equals(rlpsm.getMessageresult()))) {
//                    falseDialogShow("获取验证码失败,请重新获取！");
//                }

            }

            @Override
            public void onFailure(HttpException error, String msg) {
                falseDialogShow("网络异常");
            }
        });
    }
    private void platformInfoForApp(){
        RequestParams params = new RequestParams();
        params.addBodyParameter("sign", "3");
        HttpUtils httpUtils = new HttpUtils();
        httpUtils.send(HttpRequest.HttpMethod.POST, Httpurl.URL_Platform_Inf_For_App, params, new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                Gson gson = new Gson();
                PlatformInfoForAppModel pifam = gson.fromJson(responseInfo.result, PlatformInfoForAppModel.class);
                if(!pifam.isSuccess()){
                    //falseDialogShow("获取失败!");
                    falseDialogShow(pifam.getMsg());
                    return;
                }
                PlatformInfoForAppHtml pifah=pifam.getResult().get(0);
                PlatformInfoForAppHtml.htmlStr=pifah.getContent();
                Intent intent=new Intent(InvestPaymentActivity.this,InvestAgreementActivity.class);
                startActivity(intent);
            }

            @Override
            public void onFailure(HttpException error, String msg) {
                falseDialogShow("网络异常");
            }
        });
    }

    private boolean isLogin(){
        if(phoneNumber==null||phoneNumber.equals("")||phoneNumber.length()==0){
            return false;
        }
        return true;
    }
}
